package com.dxl.common.model;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

/**
 * EasyUI返回JSON对象类
 * @author 邓小林
 * 创建时间：2016年4月12日
 */
public class RespData implements Serializable {
	private static final long serialVersionUID = 3597880003658479521L;
	public static final boolean SUCCESS = true;
	public static final boolean FAIL = false;
	private boolean success = false;
	private String msg = "";
	private Object data;
	
	private RespData(boolean success) {
		this.success = success;
	}
	private RespData(boolean success, String msg) {
		this(success);
		this.msg = msg;
	}
	private RespData(boolean success, Object data) {
		this(success);
		this.data = data;
	}
	private RespData(boolean success, String msg, Object data) {
		this(success, msg);
		this.data = data;
	}
	
	public static final RespData instance(boolean success) {
		return new RespData(success);
	}
	
	public static final RespData instance(boolean success, String msg) {
		return new RespData(success, msg);
	}
	
	public static final RespData instance(boolean success, Object data) {
		return new RespData(success, data);
	}
	
	public static final RespData instance(boolean success, String msg, Object data) {
		return new RespData(success, msg, data);
	}
	
	public boolean isSuccess() {
		return success;
	}
	public String getMsg() {
		return msg;
	}
	public Object getData() {
		return data;
	}
	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}
}
